<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>资金放款报表 管理</title>
    <style type="text/css">
        .searchArea .fieldBox .label{width: 70px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="fieldBox">
                        <div class="label">承租人</div>
                        <div class="field">
                            <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                        </div>
                    </div>
                    <div class="fieldBox">
                        <div class="label">省公司</div>
                        <div class="field">
                            <input name="cstMgrOrgCdNm" id="cstMgrOrgCdNm" data-value="" placeholder="请选择" ltype="combobox">
                        </div>
                    </div>
                    <div class="fieldBox">
                        <div class="label">创建时间</div>
                        <div class="field">
                            <input ligerui="width: 84" name="crtTmMin" id="crtTmMin" type="text" class="ui-datepicker"
                                   value="">
                            -
                            <input ligerui="width: 84" name="crtTmMax" id="crtTmMax" type="text" class="ui-datepicker"
                                   value="">
                        </div>
                    </div>
                    <div class="fieldBox">
                        <div class="label">事业部</div>
                        <div class="field">
                            <input name="buOrgCd" id="buOrgCd" data-value="" placeholder="请选择" ltype="combobox">
                        </div>
                    </div>
                    <div class="fieldBox">
                        <div class="label">项目类型</div>
                        <div class="field">
                            <input name="prjTypCd" id="prjTypCd" data-value="" placeholder="请选择" ltype="combobox">
                        </div>
                    </div>
                    <div class="fieldBox">
                        <div class="label">支付表号</div>
                        <div class="field">
                            <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
                        </div>
                    </div>
                    <div class="fieldBox">
                        <div class="label">流程号</div>
                        <div class="field">
                            <input name="prInsNo" id="prInsNo" type="text" class="ui-textbox" value="">
                        </div>
                    </div>
                    <%--<div class="clearFix"></div>--%>
                    <%--<div class="formBtns noRight">--%>
                        <%--<span id="searchBtn" class="sq-button sq-button-round"></i>查询</span>--%>
                        <%--<span id="clearBtn" class="sq-button sq-button-round"></i>清空</span>--%>
                        <%--<input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>--%>
                    <%--</div>--%>
                </div>
                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round"></i>查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round"></i>清空</span>
                    <%--<sys:funcAuth resCd="exportDecomList">
                        <span id="exportXlsBtn" class="sq-button sq-button-round">导出</span>
                    </sys:funcAuth>--%>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null,callback=null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/capital/capPayListRep/initList.do',
            method: 'get',
            columns: [
                {display: '流程编号', name: 'prInsNo', minWidth: 100, align: 'left', enabledSort: false},
                {display: '支付表号', name: 'paySchNo', width: 150, align: 'left', enabledSort: false},
                {display: '省公司', name: 'cstMgrOrgCdNm', width: 130, align: 'left', enabledSort: false},
                {display: '节点', name: 'ruTaskNm', minWidth: 100, align: 'left', enabledSort: false},
                {display: '创建时间', name: 'prCrtTm', minWidth: 130, align: 'left', enabledSort: false,render:renderDate},
                {display: '客户名称', name: 'cstNm', minWidth: 100, align: 'left', enabledSort: false},
                {display: '收款单位/人', name: 'rcptUnt', minWidth: 100, align: 'left', enabledSort: false},
                {display: '收款银行', name: 'payeeBkNm', minWidth: 100, align: 'left', enabledSort: false},
                {display: '收款账号', name: 'accNo', minWidth: 100, align: 'left', enabledSort: false},
                {display: '事业部', name: 'buOrgCdNm', minWidth: 100, align: 'left', enabledSort: false},
                {display: '项目类型', name: 'prjTypCdNm', minWidth: 100, align: 'left', enabledSort: false},
                {display: '租赁物名称', name: 'prdNm', minWidth: 100, align: 'left', enabledSort: false},
                {display: '设备单价', name: 'prdAmt', minWidth: 100, align: 'left', enabledSort: false,
                    render:function(rowdata,index,value){
                        if(rowdata.prdAmt){
                            return '&yen;'+FormatMoney(rowdata.prdAmt/100);
                        }
                    }
                },
                {display: '应付金额', name: 'payAmt', minWidth: 100, align: 'left', enabledSort: false,
                    render:function(rowdata,index,value){
                        if(rowdata.payAmt){
                            return '&yen;'+FormatMoney(rowdata.payAmt/100);
                        }
                    }
                },
                {display: '应收首期租金', name: 'fstRentAmt', minWidth: 100, align: 'left', enabledSort: false,
                    render:function(rowdata,index,value){
                        if(rowdata.fstRentAmt){
                            return '&yen;'+FormatMoney(rowdata.fstRentAmt/100);
                        }
                    }
                },
                {display: '应收保证金', name: 'grtAmt', minWidth: 100, align: 'left', enabledSort: false,
                    render:function(rowdata,index,value){
                        if(rowdata.grtAmt){
                            return '&yen;'+FormatMoney(rowdata.grtAmt/100);
                        }
                    }
                },
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: true,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: false
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();
        //事业部
        $("#buOrgCd").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        liger.get("buOrgCd").setData(${buOrgCdList});
        //项目类型
        $("#prjTypCd").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        liger.get("prjTypCd").setData(${prjTypCdList});
        //省公司
        $("#cstMgrOrgCdNm").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        liger.get("cstMgrOrgCdNm").setData(${sysOrgVOList});
        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
        });

        callback = function () {
            grid.reload();
        };

        /* 新增 */
        $("#addBtn").click(function (event) {
            $.ligerDialog.open({
                width: 550,
                height: 500,
                title: '新增资金放款报表',
                url:'<%=path%>/capital/capPayListRep/toAddPage.do'
            });
            //Add_navTab("CapPayListRep_1", "新增资金放款报表", '<%=path%>/capital/capPayListRep/toAddPage.do', callback);
        });

        /* 修改 */
        $("#changeBtn").click(function (event) {
            var selectedRows = grid.getSelectedRows();
            if (selectedRows.length != 1) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
                return;
            }
            var _id=selectedRows[0].id;
            $.ligerDialog.open({
                width: 550,
                height: 500,
                title: '修改资金放款报表',
                url:'<%=path%>/capital/capPayListRep/toModifyPage.do?id='+_id
            });
            //Add_navTab('CapPayListRep_2'+_id, "修改资金放款报表", '<%=path%>/capital/capPayListRep/toModifyPage.do?id='+_id, callback);
        });

        /* 删除 */
        $("#delBtn").click(function () {
            var selectedRows = grid.getSelectedRows();
            if (selectedRows.length == 0) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW, SQ_type: "warning"});
                return;
            }
            var _ids = [];
            for (var index in selectedRows) {
                _ids.push(selectedRows[index].id);
            }

            $.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
                if (flag == false)return;
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: {ids: JSON.stringify(_ids)},
                    url: '<%=path%>/capital/capPayListRep/removeByIds.do',
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({
                            content: LogUtils.LOG_CMM_DATA_LOADING,
                            SQ_type: "waitting"
                        });
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            grid.reload();
                        } else {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }
                    }
                });
            });
        });
        //导出
        $("#exportXlsBtn").click(function (event) {
            var selectedRows = grid.getSelectedRows();
            console.log(selectedRows);
            if (selectedRows.length == 0) {
                var form = liger.get("searchBar");
                var data = form.getData();
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType:'json',
                    url: '<%=path%>/capital/capPayListRep/exportCapLoanList.do',
                    data:data,
                    beforeSend:function(){
                        wait_dialog=$.ligerDialog.SQalert({content: '正在导出...',SQ_type: "waitting"});
                    },
                    success: function(msg){
                        wait_dialog.close();
                        if(msg.success == 1){
                            window.open(msg.data);
                        }else{
                            $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                        }
                    }
                });
            }else{
                var _ids = [];
                for (var index in selectedRows) {
                    _ids.push(selectedRows[index].id);
                }
                console.log(_ids.size);
                $.ligerDialog.confirm(LogUtils.LOG_CONFIRM_EXPORT_CONTENT, function (flag) {
                    if (flag == false)return;
                    var wait_dialog;
                    $.ajax({
                        type: 'post',
                        dataType: 'json',
                        data: {ids: JSON.stringify(_ids)},
                        url: '<%=path%>/capital/capPayListRep/exportExcelByIds.do',
                        beforeSend: function () {
                            wait_dialog = $.ligerDialog.SQalert({
                                content: LogUtils.LOG_CMM_DATA_LOADING,
                                SQ_type: "waitting"
                            });
                        },
                        success: function (msg) {
                            wait_dialog.close();
                            if (msg.success == 1) {
                                $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                                grid.reload();
                            } else {
                                $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                            }
                        }
                    });
                });
            }
        });
    });

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

</script>

</body>
</html>
